/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server;

import java.io.*;
import java.net.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author sun
 */
public class MT extends Thread {

    Socket soc;
    boolean isAlive;
    InputStream is = null;
    OutputStream os = null;
    SE se;
    String mname;
    BufferedWriter out;
    public MT(Socket soc,SE s) {
        this.soc = soc;
        isAlive = true;
    }
    public String getmName(){
        return mname;
    }
    
    public void setmName(String n){
        mname = n;
    }
    public void send(String send ){
        try {
            out.write(send);
            out.flush();
        } catch (IOException ex) {
            Logger.getLogger(MT.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    @Override
    public void run() {
        try {
            is = soc.getInputStream(); 	// 输入流的获取
            os = soc.getOutputStream(); 	// 输出流的获取
            BufferedReader in = new BufferedReader(new InputStreamReader(is));
           out  = new BufferedWriter(new OutputStreamWriter(os));
           out.flush();
            while (true) {
                String n = in.readLine();
                System.out.println(n);
                se.proc(n,this);
            }
        } catch (IOException ex) {
            Logger.getLogger(MT.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}
